package engine

import (
	"demo/web/gin/middleware"
	"demo/web/gin/router"
	"demo/web/gin/router/params"
	"github.com/gin-gonic/gin"
	"os"
	"path/filepath"
)

func GetCurrentPath() string {
	if ex, err := os.Executable(); err != nil {
		path, _ := filepath.Abs(ex)
		return path
	}

	path, _ := filepath.Abs("./")
	return path
}

func SetRouter(engine *gin.Engine) {
	engine.Use(middleware.StatCost())

	//静态路由
	router.StaticRoute(engine)
	//基本路由
	router.BaseRoute(engine)
	//json
	router.JsonRoute(engine)
	//xml
	router.XMLRoute(engine)
	//protobuf
	router.ProtobufRoute(engine)

	//提取参数
	params.ParamRoute(engine)
	//bind提取
	params.BindRoute(engine)

	//router group
	router.GroupRoute(engine)
	//重定向
	router.RedirectRoute(engine)
	//其他路由
	router.AnyRoute(engine)
}
